<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Rectangle {

            constructor(width,height) {
                this.width = width;
                this.height = height;
            }

            area() {
                console.log("面积：",this.width * this.height)
                return this.width * this.height;
            }

            perimeter() {
                console.log("周长：",2 * (this.width + this.height))
                return 2 * (this.width + this.height);
            }
        }

        let react1 = new Rectangle(100,50);
        react1.area();
        react1.perimeter();

        let react2 = new Rectangle(10,5);
        react2.area();
        react2.perimeter();

        class Square extends Rectangle {

            constructor(a) {
                super(a,a);
            }

        }

        let square1 = new Square(10);
        square1.area();
        square1.perimeter();

    </script>
</body>
</html>